<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'record.jsp' starting page</title>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/easyui/1.3.4/themes/default/easyui.css" />
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/wu.css" />
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/icon.css" />
	<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-1.8.0.min.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/easyui/1.3.4/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/easyui/1.3.4/locale/easyui-lang-zh_CN.js"></script>

<script type="text/javascript">
	$(function(){
		$('#starttime').datetimebox({   
		    showSeconds: false  
		});
		$('#endtime').datetimebox({   
		    showSeconds: false 
		});
		$("#search").click(function(){
			var realname = $("#realname").val();
			var starttime = $("#starttime").datetimebox("getValue");
			var endtime = $("#endtime").datetimebox("getValue");
			$("#tab").datagrid('load',{
				realname:realname,
				starttime:starttime,
				endtime:endtime
			});
		});
		
		$("#tab").datagrid({   
		    url:'${pageContext.request.contextPath}/record?op=showinfo',   
		    columns:[[   
		        {field:'id',title:'编号'},   
		        {field:'user',title:'用户名',width:50,
		        	formatter:function(value,row,index){
		        		return value.realname;
		        	}
		        },   
		        {field:'role',title:'角色',width:50,
		        	formatter:function(value,row,index){
		        		return row.user.role.rolename;
		        	}
		        } ,
		        {field:'eventinfo',title:'事件',width:200,align:'center'} ,
		        {field:'time',title:'操作时间',width:100,
	       			formatter:function(value,row,index){
		        		return timeformat(value);
		        	}
		        }
		    ]],
		    fitColumns : true,
			striped : true,
			loadMsg : '请等待...',
			pagination : true,
			nowrap : true,
			fit : false ,
			singleSelect:true
		});  
	});
	
	//转换时间
		function add0(m){return m<10?'0'+m:m; };
		function timeformat(timestamp){
		  //timestamp是整数，否则要parseInt转换,不会出现少个0的情况
			var time = new Date(timestamp);
			var year = time.getFullYear();
			var month = time.getMonth()+1;
			var date = time.getDate();
			var hours = time.getHours();
			var minutes = time.getMinutes();
			var seconds = time.getSeconds();
			return year+'-'+add0(month)+'-'+add0(date)+' '+add0(hours)+':'+add0(minutes)+':'+add0(seconds);
		}
</script>
  </head>
  
  <body>
  	
  	  	用户名：<input name="realname" id="realname" value="${realname }">
  		时间段：<input id="starttime" type="text" name="starttime"></input>
  		至 <input id="endtime" type="text" name="endtime"></input>
  		<a href="javascript:void(0)" id="search" class="easyui-linkbutton">查询</a> 
  		<p></p>
    	<table id="tab"  style="width: auto; height: auto;"></table>
   
  </body>
</html>
